
//找标签
let bannerUl = document.querySelector("#bannerUl");
let li = bannerUl.children;
let bannerCtrl = document.getElementById("bannercontrol");
//初始化span
for(let i=0;i<=li.length-1;i++){
	let span = document.createElement("span");
	bannerCtrl.appendChild(span);
	if(i==0){
		span.classList.add("on");
	}
}
//初始化样式
li[0].classList.add("show");

//显示图片函数
function showPic(i){
	//图片切换 点的切换
	li[i].classList.add("show");
	spanAll[i].classList.add("on");
	//去掉其他标签的类 其他标签：索引不为i的标签
	for(let j=0;j<=spanAll.length-1;j++)
	{
		if(j!=i)
		{
			li[j].classList.remove("show");
			spanAll[j].classList.remove("on");
		}
	}
}
//点击事件
let spanAll = bannerCtrl.children;
for(let i=0;i<=spanAll.length-1;i++){
	spanAll[i].addEventListener("click",function(){
		showPic(i); //调用函数showPic()
	});
}